package handlers

import (
	"github.com/gin-gonic/gin"
	"pic-text-sys/models"
	"strconv"
)

func List(c *gin.Context) {
	page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
	size, _ := strconv.Atoi(c.DefaultQuery("size", "3"))
	offset := (page - 1) * size

	var article []models.Article
	models.DB.Offset(offset).Limit(size).Find(&article)
	c.JSON(200, gin.H{
		"code": 200,
		"data": article,
		"msg":  "ok",
	})
	return
}
